import { PlayerDialog } from "./PlayerDialog";
import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { OperateItem } from "./OperateItem";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
type int = number;
//class OperateList
    
    export  class OperateList extends PlayerDialog
    {
        constructor()
        {
            super();
            this._bodySprite = new GBox();
            this._bodySprite.mouseEnabled = false;
            this._bodySprite.direction = GBoxDirection.VERTICAL;
            addChild(this._bodySprite);
            return;
        }

        public /* override */ getOperteItem(arg1: int): OperateItem
        {
            var loc2=null;
            var loc1=0;
            while (loc1 < this._bodySprite.numChildren) 
            {
                loc2 = this._bodySprite.getChildAt(loc1) as OperateItem;
                if (loc2 != null) 
                {
                    if (loc2.operateInfo.operateId == arg1) 
                    {
                        return loc2;
                    }
                }
                ++loc1;
            }
            return super.getOperteItem(arg1);
        }

        public /* override */ updateData(arg1: Array<any>): void
        {
            var loc3=null;
            var loc4=null;
            var loc1=0;
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                loc3 = arg1[loc1];
                (loc4 = ObjectPool.getObject(OperateItem)).updateData(loc3);
                this._bodySprite.addChild(loc4);
                ++loc1;
            }
            this._bodySprite.invalidate();
            super.updateData(arg1);
            return;
        }

        public /* override */ dispose(): void
        {
            var loc1=null;
            super.dispose();
            while (this._bodySprite.numChildren > 0) 
            {
                loc1 = this._bodySprite.getChildAt(0) as OperateItem;
                this._bodySprite.removeChild(loc1);
                loc1.dispose();
                ObjectPool.disposeObject(loc1, OperateItem);
            }
            return;
        }

        public /* override */ get height(): number
        {
            var loc1=0;
            var loc3=null;
            var loc4=0;
            var loc2=this._bodySprite.numChildren;
            while (loc1 < loc2) 
            {
                loc3 = this._bodySprite.getChildAt(loc1);
                loc4 = loc4 + loc3.height;
                ++loc1;
            }
            return loc4;
        }

        /* internal */ /* var */_bodySprite: GBox;
    }
